<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
    <style>
        button.active{
            background:#f00;
        }
        .content>div{
            width:200px;
            height:200px;
            border:1px solid #ccc;
            text-align:center;
            line-height: 200px;
            font-size:50px;
        }
    </style>
</head>
<body>
    <div id="app">
        <button v-for="(title,index) in arr"  
            @click="tab(index)" 
            :class="{ active:num===index }">
            {{ title.title }}</button>
        
        <div class="content">
            <div v-for="(content,index) in arr" v-show="num===index">
                {{ content.content }}
            </div>
            
        </div>
    </div>
    <script>
        let vm = new Vue({
            el:"#app",
            data:{
                num:0, //控制元素显示消失 以及 active类名处理
                arr:[
                    {
                        title:"标题1",
                        content:"内容1"
                    },
                    {
                        title:"标题2",
                        content:"内容2"
                    },
                    {
                        title:"标题3",
                        content:"内容3"
                    },
                ]
            },
            methods:{
                tab(index){
                    this.num = index;
                }
            }
        })
    </script>
</body>
</html>